// $Id$
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Xml.Serialization;
using Salamanca.DataAccess;
using Salamanca.DataAccess.Collections;
using Salamanca.DataRules;
#if (!NET_CF)
using System.Diagnostics.CodeAnalysis;
#endif

namespace Northwind.DomainModel
{

    /// <summary />
    partial interface ICustomerContainer
    {
        /// <summary />
      Customer Customer
        {
            get;
            set;
        }

    }

    /// <summary />
    partial interface ICustomerMapper
    {

        /// <summary />
        Customer Find(Customer.PrimaryKey key, DataMapperCollection dataMappers);
        /// <summary />
        DomainModelKeyedCollection<Customer> FindAll(DataMapperCollection dataMappers);

    }

    /// <summary />
    partial class Customer
    {

        /// <summary />
        partial class PrimaryKey
        {
            /// <summary />
            public static implicit operator PrimaryKey(string key)
            {
                return new PrimaryKey(key);
            }

            /// <summary />
            public static explicit operator string(PrimaryKey key)
            {
                return key.Value;
            }

        }

        /// <summary />
        partial class DataTransfer
        {
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string CustomerID;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string CompanyName;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string ContactName;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string ContactTitle;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string Address;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string City;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string Region;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string PostalCode;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string Country;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string Phone;
            /// <summary />
#if (!NET_CF)
            [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
#endif
            public string Fax;

            /// <summary />
            public object Clone()
            {
                return MemberwiseClone();
            }

        }

        /// <summary />
        protected override Customer.PrimaryKey CreateId()
        {
            return new Customer.PrimaryKey(Data.CustomerID);
        }

        /// <summary />
        internal Customer.PrimaryKey GetId()
        {
            return Id;
        }

        /// <summary />
        internal void SetId(string id)
        {
            Data.CustomerID=id;
        }


        /// <summary />
#if (!NET_CF)
        [DataObjectMethod(DataObjectMethodType.Select, false)]
#endif
        public static Customer Find(Customer.PrimaryKey key, DataMapperCollection dataMappers)
        {
            return ((ICustomerMapper)dataMappers[typeof(Customer)]).Find(key, dataMappers);
        }

        /// <summary />
#if (!NET_CF)
        [DataObjectMethod(DataObjectMethodType.Select, true)]
#endif
        public static IList<Customer> FindAll(DataMapperCollection dataMappers)
        {
            return ((ICustomerMapper)dataMappers[typeof(Customer)]).FindAll(dataMappers);
        }

        /// <summary />
        internal bool InternalIsNew
        {
            get
            {
                return IsNew;
            }
        }

        /// <summary />
        private string _CompanyNameProperty
        {
            get
            {
                Load(true);
                return Data.CompanyName;
            }
            set
            {
                if (Data.CompanyName!=value)
                {
                    Data.CompanyName=value;
                }
            }
        }

        /// <summary />
        private string _ContactNameProperty
        {
            get
            {
                Load(true);
                return Data.ContactName;
            }
            set
            {
                if (Data.ContactName!=value)
                {
                    Data.ContactName=value;
                }
            }
        }

        /// <summary />
        private string _ContactTitleProperty
        {
            get
            {
                Load(true);
                return Data.ContactTitle;
            }
            set
            {
                if (Data.ContactTitle!=value)
                {
                    Data.ContactTitle=value;
                }
            }
        }

        /// <summary />
        private string _AddressProperty
        {
            get
            {
                Load(true);
                return Data.Address;
            }
            set
            {
                if (Data.Address!=value)
                {
                    Data.Address=value;
                }
            }
        }

        /// <summary />
        private string _CityProperty
        {
            get
            {
                Load(true);
                return Data.City;
            }
            set
            {
                if (Data.City!=value)
                {
                    Data.City=value;
                }
            }
        }

        /// <summary />
        private string _RegionProperty
        {
            get
            {
                Load(true);
                return Data.Region;
            }
            set
            {
                if (Data.Region!=value)
                {
                    Data.Region=value;
                }
            }
        }

        /// <summary />
        private string _PostalCodeProperty
        {
            get
            {
                Load(true);
                return Data.PostalCode;
            }
            set
            {
                if (Data.PostalCode!=value)
                {
                    Data.PostalCode=value;
                }
            }
        }

        /// <summary />
        private string _CountryProperty
        {
            get
            {
                Load(true);
                return Data.Country;
            }
            set
            {
                if (Data.Country!=value)
                {
                    Data.Country=value;
                }
            }
        }

        /// <summary />
        private string _PhoneProperty
        {
            get
            {
                Load(true);
                return Data.Phone;
            }
            set
            {
                if (Data.Phone!=value)
                {
                    Data.Phone=value;
                }
            }
        }

        /// <summary />
        private string _FaxProperty
        {
            get
            {
                Load(true);
                return Data.Fax;
            }
            set
            {
                if (Data.Fax!=value)
                {
                    Data.Fax=value;
                }
            }
        }


        /// <summary />
        public static readonly IdentityMap<Customer.PrimaryKey, Customer> IdentityMap=new IdentityMap<Customer.PrimaryKey, Customer>();

    }

}
